<template>
    <div>
        <div class="btn" @click="logout">退出登录</div>
    </div>
</template>

<script>

export default {
    data() {
        return {
        }
    },
    methods: {
        // 退出登录
        logout() {
            // 删除token
            localStorage.clear();
            // 提示退出成功
            let obj = { content: "您已退出,即将返回首页", icon: "success" };
            this.$store.dispatch("AsyncToast", obj);
            this.$emit("updatekeyFn");
            setTimeout(() => {
                this.$router.push("/");
            }, 2000)
        }
    }
}
</script>
 
<style lang = "less" scoped>
@import '../../assets/base.less';

.btn {
    width: 100px;
    height: 40px;
    line-height: 40px;
    color: #fff;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
    cursor: pointer;
    background: @blue;
}
</style>